import 'package:app/common/colors.dart';
import 'package:app/pages/personnel_module/department_staff_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:get/get.dart';
import 'package:getwidget/components/checkbox/gf_checkbox.dart';
import 'package:getwidget/types/gf_checkbox_type.dart';

import '../../common/app_theme.dart';
import '../../services/address.dart';
import '../../services/dio_manager.dart';

class DepartmentStaffView extends StatefulWidget {


  var department_id;

   DepartmentStaffView({Key? key,this.department_id}) : super(key: key);

  @override
  State<DepartmentStaffView> createState() => _DepartmentStaffViewState();
}

class _DepartmentStaffViewState extends State<DepartmentStaffView> {



  DepartmentStaffModel? departmentStaffModel;

  /// 获取部门员工
  requestDataWithHrEmployeePage(var department_id) async {

    var params = {
      ''
    };
    var json = await DioManager().kkRequest('${Address.hrEmployeePageRead}/${department_id}', method: 'get');


    DepartmentStaffModel model = DepartmentStaffModel.fromJson(json);

    departmentStaffModel = model;
    setState(() {

    });
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    requestDataWithHrEmployeePage(widget.department_id);
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: AppColor.themeColor,
        leading: IconButton(
          onPressed: () {
            Get.back();
          },
          icon: Image.asset(
            'images/leftarr.png',
            width: 15,
            height: 15,
            color: Colors.white,
          ),
        ),
        title: Text('选择对象'),
      ),
      body: ListView.builder(itemBuilder: (BuildContext context, int index) {
        return Container(

          child:Column(
            children: [
              Container(
                padding: EdgeInsets.all(10),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Row(
                      children: [
                        CircleAvatar(
                          backgroundImage: NetworkImage(
                            '${Address.homeHost}${departmentStaffModel?.data?[index].image128}',
                          ),
                        ),
                        Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Text('${departmentStaffModel?.data?[index].name}',style: appThemeData.textTheme.bodyText1,),
                            Text('${departmentStaffModel?.data?[index].department}',style: appThemeData.textTheme.subtitle1,)
                          ],
                        ),
                      ],
                    ),
                    GFCheckbox(
                      onChanged: (bool value) {

                      },
                      size: 25,
                      type: GFCheckboxType.circle,
                      value: false,
                    )
                  ],
                ),
              ),
              Container(
                color: AppColor.lineColor,
                height: 0.5,
              )
            ],
          ),
        );
      },itemCount: departmentStaffModel?.data?.length,),
    );
  }
}
